﻿#pragma once

#include <QWidget>

#include "../gant_global_define.h"

class GAntFramelessWidgetPrivate;
class GANT_EXPORT GAntFramelessWidget : public QWidget
{
    Q_OBJECT
        
public:
    explicit GAntFramelessWidget(QWidget* parent = nullptr);
    ~GAntFramelessWidget();

    QWidget* titleBar() const;
    void setTitleBar(QWidget* titleBar);

    QWidget* contentWidget() const;
    void setContentWidget(QWidget* content);

    void setMaximumWidth(int maxw);
    void setMaximumHeight(int maxh);
    void setMinimumWidth(int minw);
    void setMinimumHeight(int minh);

    void setMaximumSize(const QSize& maxiSize);
    void setMaximumSize(int maxw, int maxh);
    void setMinimumSize(const QSize& miniSize);
    void setMinimumSize(int minw, int minh);

    void setFixedWidth(int width);
    void setFixedHeight(int height);
    void setFixedSize(const QSize& size);
    void setFixedSize(int width, int height);

    void setMoveable(bool moveable);
    bool isMoveable() const;

protected:
    void paintEvent(QPaintEvent* event) override;

    void mousePressEvent(QMouseEvent* event) override;
    void mouseMoveEvent(QMouseEvent* event) override;
    void mouseReleaseEvent(QMouseEvent* event) override;

    void resizeEvent(QResizeEvent* event) override;

    bool eventFilter(QObject* watched, QEvent* event) override;

private:
    GANT_DECL_PRIVATE(GAntFramelessWidget)
};

inline void GAntFramelessWidget::setMinimumSize(const QSize& s)
{
    setMinimumSize(s.width(), s.height());
}

inline void GAntFramelessWidget::setMaximumSize(const QSize& s)
{
    setMaximumSize(s.width(), s.height());
}